home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11820 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: due.unit.no!hff44-52
  2. From: davidk@james.stud.unit.no (David Kaasen)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: FORTRAN and floats
  5. Date: 26 Mar 1996 17:34:41 GMT
  6. Organization: NTNU
  7. Message-ID: <4j99rh$5bj@due.unit.no>
  8. References: <4j6on8$fif@mozo.cc.purdue.edu>
  9. NNTP-Posting-Host: hfl216.avh.unit.no
  10. X-Newsreader: News Xpress Version 1.0 Beta #4
  11.  
  12. Hello,
  13. I know the safest way of doing this: write the float numbers as
  14. textstrings. That is, let myFloat be a textfile and use 
  15.    fprintf(fOut,"%f",myFloat)
  16. instead. One drawback of this method is that it will require some
  17. more diskspace. I don't know much FORTRAN, but I am sure it can
  18. read textformatted floatingpoint numbers from a file.
  19.  
  20. David Kaasen <davidk@james.stud.unit.no>
  21.  
  22. In article <4j6on8$fif@mozo.cc.purdue.edu>, rwa@bragg.bio.purdue.edu wrote:
  23. >I write a "float" from C in Ultrix to a disk file as follows:
  24. >    fwrite(&myFloat,sizeof(float),1,fOut);
  25. >I get over to my Alpha Open VMS box and try and read it with FORTRAN and
  26. >get gibberish.  (Also can't do when writing from FORTRAN/VMS and reading in 
  27. Ultrix/C).
  28. >So FORTRAN/VMS likes a different format for floats than C/Ultrix.
  29. >This is a portability issue that I'm sure there's a "clean" way to
  30. >solve it - does anyne have any ideas for me???
  31. >Rob
  32. >rwa@babe.bio.purdue.edu
  33.